package com.cdn.allmobilestore.adapter;


import android.content.Context;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import com.cdn.allmobilestore.R;
import com.cdn.allmobilestore.model.AppInfo;
import com.cdn.allmobilestore.ui.ListAppListItem;

public class ListAppAdapter extends BaseDataAdapter<AppInfo> implements AbsListView.RecyclerListener
{
  protected LayoutInflater mInflater;
  private DisplayMetrics _metrics;
  public ListAppAdapter(Context context,DisplayMetrics metrics/*, int headerViewCount*/)
  {
    super(context);
    _metrics = metrics;
    this.mInflater = LayoutInflater.from(context);
  }

  public void bindView(View view, int position, AppInfo data)
  {    
	  ((ListAppListItem)view).rebind(data,position+1);
	  Animation animation = null;  
	  //animation = new TranslateAnimation(_metrics.widthPixels/2, 0, 0, 0);
	  //animation = new ScaleAnimation((float)1.0, (float)1.0 ,(float)0, (float)1.0);
	  animation = new TranslateAnimation(0, 0, _metrics.heightPixels/3, 0);  
	  animation.setDuration(850);  
	  //view.startAnimation(animation);  
	  animation = null; 
  }


  public int getCount()
  {	 
    return super.getCount();
  }

  public View newView(Context context, AppInfo appinfo, ViewGroup parent)
  {
	    ListAppListItem item = (ListAppListItem)this.mInflater.inflate(R.layout.listapp_list_item, parent, false);
	    item.bind(appinfo);	    
	    return item;
  }
  
  @Override
	public boolean isEnabled(int position) {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void onMovedToScrapHeap(View view) {
			((ListAppListItem)view).unbind();	
		}

}

